package com.foreknow.demo5;

public class Order {
    private String orderId;
    private double total;
    private Orderltem[] items;
    public Order(String orderId){
        this.orderId = orderId;
        this.items = new Orderltem[3];
    }
    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public double getTotal() {
        return total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public Orderltem[] getItems() {
        return items;
    }

    public void setItems(Orderltem items,int i) {
        this.items[i] = items;
    }
    public void caltotal(){
        double total = 0;
        if (items != null){
            for (int i = 0;i<items.length;i++){
                total += items[i].getPrice() * items[i].getNum();
            }
        }
        this.total = total;
        System.out.println(this.total);
    }
}
